/**
 * @description: 存储库: 系统主题配置
 */
const useThemeStore = defineStore("themeStore", {
  state: () => {
    return {
      theme: "auto", // 主题名称 auto | dark
      layoutMode: "MixMode", // 布局模式 MixMode | LeftMode | TopMode | ModularMode
      collapse: false, // 菜单是否收缩
      lightParentMenu: false, // 父菜单是否高亮
    };
  },
  // 开启本地缓存
  persist: {
    enabled: true,
    strategies: [
      {
        storage: localStorage, //表示存储在localStorage
        paths: ["theme", "layoutMode", "collapse", "lightParentMenu"],
      },
    ],
  },
});

// 监视: 菜单收缩
watch(
  () => useThemeStore().collapse,
  (newValue) => {
    if (newValue) {
      document.documentElement.style.setProperty("--custom-aside-width", "66px");
    } else {
      document.documentElement.style.setProperty("--custom-aside-width", "200px");
    }
  },
  {
    immediate: true,
  }
);

export default useThemeStore;
